home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 27
/
Mac Magazin and MacEasy Magazine CD - Issue 27.iso
/
Grafik & Text
/
Sans-Faute⁄Grammaire ƒ
/
Adaptateurs
/
Sources des scripts (anglais)
/
Vérification QuarkXPress®
< prev
next >
Wrap
Text File
|
1996-02-20
|
4KB
|
100 lines
set kMaxStorySize to 10000 -- max number of characters of a story for checking it in one time
set kMaxCheckingSFG to 32000 -- max number of characters that Sans-Faute/Grammaire can check
set knbParagraphMaxToCheck to 25 -- max number of paragraphs sent to Sans-Faute/Grammaire
tell application "QuarkXPress®"
set FrontDocPresent to exists front document
end tell
if FrontDocPresent then
tell application "QuarkXPress®"
set nbStory to count stories of front document
end tell
-- loop on each story
repeat with storyIdx from 1 to nbStory
tell application "QuarkXPress®"
set storySize to count character of story storyIdx of front document
end tell
if storySize > 0 then -- do something only for non null stories
if storySize > kMaxStorySize then -- big story -> split into bunch of paragraphs
set endParagraphIdx to 0
tell application "QuarkXPress®"
set nbParagraph to count paragraph of story storyIdx of front document
end tell
repeat while endParagraphIdx < nbParagraph
-- try to collect a maximum of paragraphs
set paragraphIdx to endParagraphIdx + 1
tell application "QuarkXPress®"
set paragraphSize to count character of paragraph paragraphIdx of story storyIdx of front document
end tell
if paragraphSize > kMaxCheckingSFG then
display dialog "Le paragraphe " & paragraphIdx & " du bloc " & storyIdx & " dépasse 32000 caractères. Sans-Faute/Grammaire ne peut pas le vérifier !"
end if
repeat while (paragraphIdx ≤ nbParagraph) and (paragraphSize > kMaxCheckingSFG)
set paragraphIdx to paragraphIdx + 1
if paragraphIdx ≤ nbParagraph then
tell application "QuarkXPress®"
set paragraphSize to count character of paragraph paragraphIdx of story storyIdx of front document
end tell
if paragraphSize > kMaxCheckingSFG then
display dialog "Le paragraphe " & paragraphIdx & " du bloc " & storyIdx & " dépasse 32000 caractères. Sans-Faute/Grammaire ne peut pas le vérifier !"
end if
end if
end repeat
set startParagraphIdx to paragraphIdx
set bunchSize to 0
set nbparagraphBunch to 0
set objToCheck to {}
repeat while (paragraphIdx ≤ nbParagraph) and (nbparagraphBunch < knbParagraphMaxToCheck) and (bunchSize + paragraphSize ≤ kMaxStorySize)
-- (paragraphSize ≤ kMaxCheckingSFG) is implicit
set bunchSize to bunchSize + paragraphSize
if paragraphSize > 0 then
set objToCheck to objToCheck & {a reference to the text of the paragraph paragraphIdx of text flow storyIdx of front document}
set nbparagraphBunch to nbparagraphBunch + 1
end if
set paragraphIdx to paragraphIdx + 1
if paragraphIdx ≤ nbParagraph then
tell application "QuarkXPress®"
set paragraphSize to count character of paragraph paragraphIdx of story storyIdx of front document
end tell
end if
end repeat
if (bunchSize = 0) and (paragraphIdx ≤ nbParagraph) and (paragraphSize ≤ kMaxCheckingSFG) then
-- kMaxStorySize <paragraphSize ≤ kMaxCheckingSFG
set objToCheck to objToCheck & {a reference to the text of the paragraph paragraphIdx of text flow storyIdx of front document}
set endParagraphIdx to paragraphIdx
set bunchSize to paragraphSize
else
set endParagraphIdx to paragraphIdx - 1
end if
if bunchSize > 0 then -- cas be zero if the end of the story contains only paragraphs > 32000
-- tell Sans-Faute/Grammaire to check the content of the list of references and made changes in Application XPress
tell application "Sans-Faute/Grammaire 2"
Checking objToCheck ClientAddress Application "QuarkXPress®"
end tell
end if
end repeat
else
-- small story -> it fits
-- prepare an object reference to entire story
set objToCheck to (a reference to the text of the text flow storyIdx of front document)
-- tell Sans-Faute/Grammaire to check the content of the reference and made changes in Application XPress
tell application "Sans-Faute/Grammaire 2"
Checking {objToCheck} ClientAddress Application "QuarkXPress®"
end tell
end if
end if
end repeat
else
display dialog "Aucun document n'est ouvert dans QuarkXPress® !"
end if